﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AutoGenerateItems : MonoBehaviour
{
    [SerializeField] private GameObject[] itemsPre;

    private event EventExtends.Vec3EventReturnObject Create;
    private ObjectPool objectPool;
    private GameObject item1Parent;



    private void Awake()
    {
        objectPool = GameObject.Find("/ObjectPool").GetComponent<ObjectPool>();
        Create = CreateMainMoudle;
        item1Parent = GameObject.Find("/CircleRoot");
    }

    private GameObject CreateMainMoudle(Vector3 pos)
    {
        GameObject _gameObject = objectPool.Pop(itemsPre[0]);
        _gameObject.transform.position = pos;
        _gameObject.transform.SetParent(item1Parent.transform);
        _gameObject.GetComponent<CircleTrigger>().enabled = true;
        return _gameObject;
    }

    public GameObject Invoke(Vector3 pos) => Create(pos);
}
